package leetcode;

/**
 * @program: datastructureandalogorithm
 * @description:
 * @author: hmx
 * @create: 2022-01-23 17:48
 **/
public class LeetCode5991 {

    public int[] rearrangeArray(int[] nums) {
        int n = nums.length;
        int[] arr = new int[n];

        int i1 = 0;
        int i2 = 1;
        for (int num : nums) {
            if (num > 0) {
                arr[i1] = num;
                i1 += 2;
            }

            if (num < 0) {
                arr[i2++] = num;
                i2 += 2;
            }
        }

        return arr;
    }

}
